<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<!-- 计划处理页面 -->
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-hatchetPlan-add">
			<!-- 拉起计划 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="planItemId" name="planItemId" placeholder="请输入计划明细id" style="width: 80%" type="text">
					<a class="btn btn-primary  btn-sm" onclick="laqiPlan()">&nbsp;拉起单个计划</a>
					<p  style="color: red">温馨提示：请在输入框里输入计划明细id,点击“拉起单个计划”按钮，可以重新拉起计划，使计划明细重新处于“未执行”状态</p>
				</div>
			</div>
			<hr>
			<!-- 立即执行计划明细 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="doPlanNow" name="doPlanNow" placeholder="请输入计划明细id" style="width: 80%" type="text">
					<a class="btn btn-warning  btn-sm" onclick="doPlanNow()">&nbsp;立即执行计划</a>
					<p style="color: red">温馨提示：请在输入框里输入计划明细id,点击“立即执行计划”按钮，可以让计划明细立即执行，点击后请关注该计划明细执行情况</p>
				</div>
			</div>
			<hr>
			<!-- 完成计划明细 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="planItemIdComplete" placeholder="请输入计划明细id"   name="planItemId" style="width: 80%" type="text">
					<a class="btn btn-primary  btn-sm" onclick="completePlan()">&nbsp;完成计划</a>
					<p style="color: red">温馨提示：请在输入框里输入计划明细id,点击“完成计划”按钮，可以修改计划明细状态为“成功”</p>
				</div>
			</div>
			<!-- 更新订单状态 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="orderNo"   name="orderNo" style="width: 80%" type="text">
					<a class="btn btn-primary  btn-sm" onclick="updateOrder()">&nbsp;更新状态</a>
					<p style="color: red">温馨提示：请在输入框订单号，并确认该订单在通道已交易成功，点击“更新状态”，更新订单信息。</p>
				</div>
			</div>
			<hr>
			
			
			----------------------- 此功能仅开发使用  ---------------------------------------------------------------
			<!-- 刷新落地商户城市 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<a class="btn btn-warning  btn-sm" onclick="flushCity()">&nbsp;刷新城市</a>
					<p style="color: red">温馨提示：项目重新启动后请点击该按钮来刷新城市落地商户</p>
				</div>
			</div>
			
			<!-- 所有用户，代理对账清账 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<a class="btn btn-warning  btn-sm" onclick="checkMoneyChange()">&nbsp;所有用户对账</a>
					<p style="color: red">温馨提示：所有用户对账</p>
				</div>
			</div>
			
			<!-- 刷新新闻 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<a class="btn btn-success  btn-sm" onclick="flushNews()">&nbsp;刷新新闻</a>
					<!-- <a class="btn btn-primary  btn-sm" onclick="flushGoods()">&nbsp;刷新app商品</a> -->
					<p style="color: red">温馨提示：项目重新启动后请点击该按钮来刷新app新闻数据</p>
				</div>
			</div>
			<!-- 刷新用户 -->
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="merNoInput"   name="merNoInput" placeholder="请输入用户编号" style="width: 80%" type="text">
					<a class="btn btn-primary  btn-sm" onclick="refreshMer()">&nbsp;刷新用户</a>
					<p style="color: red">温馨提示：请在输入框里输入用户编号，点击“刷新用户”按钮可以把用户刷新到缓存</p>
				</div>
			</div>
			
			<div class="form-group">	
				<div class="col-sm-8">
					<input id="orderNo1"   name="orderNo1" placeholder="请输入订单号" style="width: 80%" type="text">
					<input id="merchantNo1"   name="merchantNo1" placeholder="请输入商户号" style="width: 80%" type="text">
					<input id="money1"   name="money1" placeholder="请输入退还金额" style="width: 80%" type="text">
					<a class="btn btn-primary  btn-sm" onclick="refund()">&nbsp;点击退分润</a>
					<p style="color: red">温馨提示：请在对应输入框填写对应参数，次功能仅限开发使用！！！！！！！</p>
				</div>
			</div>
			
			<!-- 刷新修改代理密码（为身份证号后8位） -->
			<div class="form-group">	
				<div class="col-sm-8">
					<a class="btn btn-warning  btn-sm" onclick="updateAgentPassword()">&nbsp;更新代理密码</a>
					<p style="color: red">温馨提示：更新代理密码</p>
				</div>
			</div>
			---------------------- 此功能仅开发使用 ------------------------------------------------------------------
			
			<hr>
			<table>	
				<tr height="35">
					<td>【信用卡信息】</td>
					<td>卡号<input id="cardinfo" 
						class="bootstrap-text" style="width: 150px" />
						姓名<input id="cardinfo0" class="bootstrap-text" style="width: 100px" title="" />
						身份证<input id="cardinfo1"class="bootstrap-text" style="width: 150px" title="" />
						手机<input id="cardinfo2" name="cardinfo2" class="bootstrap-text" style="width: 100px" title="" /> 
						
					</td>
				</tr>
				<tr height="35">
					<td></td>
					<td>
						CVN<input id="cardinfo3" type="text" class="bootstrap-text" style="width: 80px" /> 
						有效期<input id="cardinfo4" type="text" class="bootstrap-text"  style="width: 80px" /> 
						<input id="cardinfosub" type="button" class="bootstrap-button"
						value="&nbsp;查询信息&nbsp;" />
						<input id="edit" type="button" class="bootstrap-button" value="&nbsp;点击修改&nbsp;" />
						<input id="cardinfo9" type="hidden"/>
					
					</td>
				</tr>
				<tr >
					<td colspan="2" style="color: red">温馨提示：请在“卡号”输入框里输入完整的信用卡卡号,然后点击“查询信息”按钮，
					上面的输入框会显示相关信息,根据需要修改输入框的信息后，点击“点击修改”按钮,提交修改信用卡信息</td>
				</tr>
				<tr height="20"></tr>
				<!-- <tr>
					<td>【快付通出款】
					<td>身份证<input id="idcard_kft"  class="bootstrap-text" style="width: 80px" />
						出款金额<input id="money_kft" class="bootstrap-text" style="width: 80px" title="" />
						<select id ="trx_kft">
							  <option value ="">交易类型</option>
							  <option value ="100">代还</option>
							  <option value="200">快捷</option>
							  <option value="0">免手续费</option>
							</select>
						银行名字<input id="bankname_kft" name="bankname_kft" class="bootstrap-text" style="width: 80px" title="" /> 
						卡号<input id="cardno_kft" name="cardno_kft" class="bootstrap-text" style="width: 80px" title="" /> 
						CVN<input id="cvn_kft" type="text" class="bootstrap-text" style="width: 80px" /> 
						有效期<input id="expdate_kft" type="text" class="bootstrap-text"  style="width: 80px" /> 
						<input id="cardinfosub_kft" type="button" class="bootstrap-button"
						value="&nbsp;查询余额&nbsp;" />
						<input id="cardinfosub1_kft"
						type="button" class="bootstrap-button" value="&nbsp;点击出款&nbsp;" />
						<input id="cardinfo9" type="hidden"/>
					</td>
				</tr> -->
				
			</table>
			<hr>
			<!-- 绑卡 -->
			<table>	
				<tr height="35">
					<td>身份证号</td>
					<td>
						<input id="idCardNumber" >
					</td>
				</tr>
				<tr height="35">
					<td>预留手机号</td>
					<td>
						<input id="bankPhone" >
					</td>
				</tr>
				<tr height="35">
					<td>银行卡号</td>
					<td>
						<input id="bankAccount" >
					</td>
				</tr>
				<tr height="35">
					<td>cvn</td>
					<td>
						<input id="cvn" >
					</td>
				</tr>
				<tr height="35">
					<td>额度</td>
					<td>
						<input id="limitMoney" >
					</td>
				</tr>
				<tr height="35">
					<td>账单日</td>
					<td>
						<input id="billDay" >
					</td>
				</tr>
				<tr height="35">
					<td>还款日</td>
					<td>
						<input id="repaymentDay" >
					</td>
				</tr>
				<tr height="35">
					<td>有效期</td>
					<td>
						<input id="expdate" >
					</td>
				</tr>
				<tr></tr>
			</table>	
			<a class="btn btn-primary  btn-sm" onclick="addCreditCard()">&nbsp;绑卡</a>
			&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;font-size: 16px">请客服认真核对数据，确保每个输入框所输数据准确无误，系统不做校验</span>
		<hr>
		<br>
		<a class="btn btn-primary  btn-sm" onclick="sortAgent()">&nbsp;代理商排名</a>
		</form>
	</div>
	<div class="col-sm-12 select-table table-striped">
		<table id="bootstrap-table" data-mobile-responsive="true"></table>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/hatchetPlan";
		//查询代理商列表
	   var prefix1 = ctx + "system/hatchetAgent";
	   var orderpayMent = ctx + "system/hatchetOrderPayment";
	  
		$(function(){
			
			var options = {
	                url: prefix1 + "/selectAgentMerCount",
	                modalName: "",
	            	exportUrl: prefix1 + "/export",
					search: false,
			        showExport: true,
	                columns: [{
			            checkbox: true
			        },
					{
						field : 'id', 
						title : 'ID',
						visible: false
					},
					{
						field : 'agentName', 
						title : '代理商名称',
						sortable: true
					},
					{
						field : 'agentNo', 
						title : '代理商编号',
						sortable: true
					},
					{
						field : 'sumMoney', 
						title : '直推经纪人数量',
						sortable: true
					}]
	        }; 	
	         $.table.init(options);
	             	
	        
			
			/**
			 * 银行卡信息查询
			 */
			$("#cardinfosub").bind("click", function() {
				var cardNo = $("#cardinfo").val().trim();
				if(cardNo==""){
					$.modal.alertError("银行卡号不能为空");
					return;
				}
				$.ajax({
					url : prefix + "/selectCreditCard",
					type : "POST",
					data: {
						"cardNo":cardNo
					},
					success : function(re) {
						var incr = re.increaseLimit;
						if(incr!=null){
							$("#cardinfo0").val(incr.bankAccountName);
							$("#cardinfo1").val(incr.idCardNumber);
							$("#cardinfo2").val(incr.bankPhone);
							$("#cardinfo3").val(incr.cvn);
							$("#cardinfo4").val(incr.expdate);
							$("#cardinfo9").val(incr.id);
						} else {
							$.modal.alertError(re.msg);
						}
						
					}
				});
			});
			
			/**
			 * 修改银行卡信息
			 */
			$("#edit").bind("click", function() {
				$.ajax({
					url : prefix + "/editCreditCard",
					type : "POST",
					data: {
						"bankAccountName":$("#cardinfo0").val().trim(),
						"idCardNumber":$("#cardinfo1").val().trim(),
						"bankPhone":$("#cardinfo2").val().trim(),
						"cvn":$("#cardinfo3").val().trim(),
						"expdate":$("#cardinfo4").val().trim(),
						"iD":$("#cardinfo9").val().trim()
					},
					success : function(re) {
						if(re.status=="SUCCESS"){
							$.modal.msgSuccess(re.msg);
						} else {
							$.modal.alertError(re.msg);
						}
					}
				});
			});
			
			
			/**
			 * 快付通余额查询
			 */
			$("#cardinfosub_kft").bind("click", function() {
				var idcard_kft = $("#idcard_kft").val().trim();
				if(idcard_kft==""){
					$.modal.alertError("身份证号不能为空");
					return;
				}
				$.ajax({
					url : prefix + "/cardinfo_kft",
					type : "POST",
					data: {
						"idcard_kft":idcard_kft.trim()
					},
					success : function(result) {
						console.log(result);
					}
				});
			});
		})
		
		
		
		//拉起单个计划
		function laqiPlan(){
			var planItemId = $("#planItemId").val().trim();
			if(planItemId.length==0){
				$.modal.alertError("请您输入小计划id");
				return;
			}
           $.ajax({
		        url:prefix+"/laqiPlan", 
		        dataType:"json",
		        type: "POST",
		       	data:"planItemId="+planItemId,
		        success:function(re){
		        	$("#planItemId").val("");
		      		if(re.status=="SUCCESS"){
		      			$.modal.msgSuccess(re.msg);
		      		} else if(re.status=="FAIL"){
		      			$.modal.alertError(re.msg);
		      		}
		        }
		    });
		}
		
		
		//立即执行小计划
		function doPlanNow(){
			var planItemId = $("#doPlanNow").val().trim();
			if(planItemId.length==0){
				$.modal.alertError("请您输入小计划id");
				return;
			}
           $.ajax({
		        url:prefix+"/doPlanNow", 
		        dataType:"json",
		        type: "POST",
		       	data:"planItemId="+planItemId,
		        success:function(re){
		        	$("#planItemId").val("");
		      		if(re.status=="SUCCESS"){
		      			$.modal.msgSuccess(re.msg);
		      		} else if(re.status=="FAIL"){
		      			$.modal.alertError(re.msg);
		      		}
		        }
		    });
		}
		
		
		//完成单个计划
		function completePlan(){
			var planItemId = $("#planItemIdComplete").val().trim();
			if(planItemId.length==0){
				$.modal.alertError("请您输入小计划id");
				return;
			}
           $.ajax({
		        url:prefix+"/completePlan", 
		        dataType:"json",
		        type: "POST",
		       	data:"planItemId="+planItemId,
		        success:function(re){
		        	$("#planItemId").val("");
		      		if(re.status=="SUCCESS"){
		      			$.modal.msgSuccess(re.msg);
		      		} else if(re.status=="FAIL"){
		      			$.modal.alertError(re.msg);
		      		}
		        }
		    });
			
		}
		
		//刷新用户
		function refreshMer(){
			var merNo = $("#merNoInput").val().trim();
			if(merNo.length==0){
				$.modal.alertError("请您输入用户编号");
				return;
			}
			$.ajax({
				url : prefix + "/refreshMer",
				type : "POST",
				data: {
					"merNo":merNo
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
			
		}
		

		//刷新城市
		function flushCity(){
			$.ajax({
				url : prefix + "/flushCity",
				type : "POST",
				data: {
				},
				success : function(re) {
					
				}
			});
			
		}
		
		//所有用户对账
		function checkMoneyChange(){
			$.ajax({
				url : prefix + "/checkMoneyChange",
				type : "POST",
				data: {
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
			
		}
		
		//刷新新闻
		function flushNews(){
			$.ajax({
				url : prefix + "/flushNews",
				type : "POST",
				data: {
				},
				success : function(re) {
					
				}
			});
		}
		
		//刷新
		function flushGoods(){
			$.ajax({
				url : prefix + "/flushGoods",
				type : "POST",
				data: {
				},
				success : function(re) {
					
				}
			});
		}
		nljl
		
		//更新代理商密码
		function updateAgentPassword(){
			$.ajax({
				url : prefix + "/updateAgentPassword",
				type : "POST",
				data: {
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
		}
		
		//增加fenrun
		function refund(){
			var orderNo1 = $("#orderNo1").val().trim();
			var merchantNo1 = $("#merchantNo1").val().trim();
			var money1 = $("#money1").val().trim();
			if(merchantNo1.length==0){
				$.modal.alertError("请您输入用户编号");
				return;
			}
			if(orderNo1.length==0){
				$.modal.alertError("请您输入订单号");
				return;
			}
			if(money1.length==0){
				$.modal.alertError("请您输入金额");
				return;
			}
			$.ajax({
				url : prefix + "/refund",
				type : "POST",
				data: {
					"orderNo1":orderNo1,
					"merchantNo1":merchantNo1,
					"money1":money1
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
			
		}
		
		 /**
		 * 添加信用卡信息
		 */
		 function addCreditCard() {
			$.ajax({
				url : prefix + "/addCreditCard",
				type : "POST",
				data: {
					"idCardNumber":$("#idCardNumber").val().trim(),
					"bankPhone":$("#bankPhone").val().trim(),
					"bankAccount":$("#bankAccount").val().trim(),
					"cvn":$("#cvn").val().trim(),
					"limitMoney":$("#limitMoney").val().trim(),
					"billDay":$("#billDay").val().trim(),
					"repaymentDay":$("#repaymentDay").val().trim(),
					"expdate":$("#expdate").val().trim()
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
		}
		 
		 
		 /**
		 * 修改订单状态
		 */
		 function updateOrder() {
			$.ajax({
				url : orderpayMent + "/updateOrder",
				type : "POST",
				data: {
					"orderNo":$("#orderNo").val().trim()
				},
				success : function(re) {
					if(re.status=="SUCCESS"){
						$.modal.msgSuccess(re.msg);
					} else {
						$.modal.alertError(re.msg);
					}
				}
			});
		}
		 
    
		function sortAgent(){
			window.location.href=ctx+"system/hatchetAgent/3";
		}
		 
		
	</script>
</body>
</html>
